home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 May / EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso / softwareupdate / system / amigados / filefunctions / example2.c < prev    next >
C/C++ Source or Header  |  1996-10-10  |  3KB  |  87 lines

  1. /***********************************************************/
  2. /*                                                         */
  3. /* Amiga C Encyclopedia (ACE)           Amiga C Club (ACC) */
  4. /* --------------------------           ------------------ */
  5. /*                                                         */
  6. /* Manual:  AmigaDOS                    Amiga C Club       */
  7. /* Chapter: File Functions              Tulevagen 22       */
  8. /* File:    Example2.c                  181 41  LIDINGO    */
  9. /* Author:  Anders Bjerin               SWEDEN             */
  10. /* Date:    93-03-15                                       */
  11. /* Version: 1.0                                            */
  12. /*                                                         */
  13. /*   Copyright 1993, Anders Bjerin - Amiga C Club (ACC)    */
  14. /*                                                         */
  15. /* Registered members may use this program freely in their */
  16. /*     own commercial/noncommercial programs/articles.     */
  17. /*                                                         */
  18. /***********************************************************/
  19.  
  20. /* This example demonstrates how to rename files and directories.  */
  21. /* It will rename a file on the Ram disk called "HighScore.dat" to */ 
  22. /* "Numbers.dat". It will also rename the directory the previous   */
  23. /* Example created ("MyDirectory") to "NewDirectory".              */ 
  24. /* (Please run Example 1 in the "Files" chapter to create the      */
  25. /* "HighScore.dat" file before you run this example.)              */
  26.  
  27.  
  28.  
  29. /* Include the dos library definitions: */
  30. #include <dos/dos.h>
  31.  
  32. /* Now we include the necessary function prototype files:         */
  33. #include <clib/dos_protos.h>       /* General dos functions...    */
  34. #include <stdio.h>                 /* Std functions [printf()...] */
  35. #include <stdlib.h>                /* Std functions [exit()...]   */
  36.  
  37.  
  38.  
  39. /* Set name and version number: */
  40. UBYTE *version = "$VER: AmigaDOS/FileFunctions/Example2 1.0";
  41.  
  42.  
  43.  
  44. /* Declared our own function(s): */
  45.  
  46. /* Our main function: */
  47. int main( int argc, char *argv[] );
  48.  
  49.  
  50.  
  51. /* Main function: */
  52.  
  53. int main( int argc, char *argv[] )
  54. {
  55.   /* A simple boolean variable: */
  56.   BOOL ok;
  57.  
  58.  
  59.  
  60.   /* Rename the file: */
  61.   ok = Rename( "RAM:HighScore.dat", "RAM:Numbers.dat" );
  62.  
  63.   /* Check if the file was successfully renamed: */
  64.   if( ok )
  65.     printf( "The file was successfully renamed!\n" );
  66.   else
  67.     printf( "Error! The file could not be renamed!\n" );
  68.  
  69.  
  70.  
  71.   /* Rename the directory: */
  72.   ok = Rename( "RAM:MyDirectory", "RAM:NewDirectory" );
  73.  
  74.   /* Check if the directory was successfully renamed: */
  75.   if( ok )
  76.     printf( "The directory was successfully renamed!\n" );
  77.   else
  78.     printf( "Error! The directory could not be renamed!\n" );
  79.  
  80.  
  81.  
  82.   /* The End! */
  83.   exit( 0 );
  84. }
  85.  
  86.  
  87.